
//not use this class in our project
package fcc.Seng462project.server;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import fcc.Seng462project.client.LoginInfo;
import fcc.Seng462project.client.LoginService;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
	
	public LoginInfo login(String requestUrl){
		UserService userService= UserServiceFactory.getUserService();
		User user=userService.getCurrentUser();
		LoginInfo loginInfo=new LoginInfo();
		if(user!=null){
			loginInfo.setLoggedIn(true);
			loginInfo.setEmailAddress(user.getEmail());
			//loginInfo.setNickname(user.getNickname());
			loginInfo.setLogoutUrl(userService.createLogoutURL(requestUrl));
		}else{
			loginInfo.setLoggedIn(false);
			loginInfo.setLoginUrl(userService.createLoginURL(requestUrl));
		}
		return loginInfo;
	}






}
